package com.rrd.dw.mr.gzip.kafka;

import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.third.pudao.PuDaoCurrentDayApplyRecord;
import com.ucredit.babel.common.model.third.pudao.PuDaoCurrentDayApplyData;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;

/**
 * 朴道-单日借贷申请
 *
 * @author guoqiang
 */
public class PuDaoCurrentDayApplyParse extends ParseBase {
    private Text val = new Text();
    private Text key = new Text();

    /**
     * 朴道-单日借贷申请
     *
     * @param model
     * @throws InterruptedException
     * @throws IOException
     */
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        PuDaoCurrentDayApplyRecord obj = (PuDaoCurrentDayApplyRecord) model;
        PuDaoCurrentDayApplyData scoreData = obj.getData();
        StringBuilder sb = getBaseInfo(obj, successful);
        sb.append(formatValue(scoreData.getFlag())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdBankAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankLoanAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankNloanAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankConsAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankFinAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankAutoAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankSafeAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankOtherAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdBankOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankLoanOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankNloanOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankConsOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankFinOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankAutoOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankSafeOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiIdNbankOtherOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellBankAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankLoanAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankNloanAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankConsAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankFinAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankAutoAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankSafeAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankOtherAllnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellBankOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankLoanOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankNloanOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankConsOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankFinOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankAutoOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankSafeOrgnum())).append(CRT001);
        sb.append(formatValue(scoreData.getPpdiCellNbankOtherOrgnum())).append(CRT001);
        key.set(getKey());
        val.set(sb.toString().replace("\n", " ").replace("\r", " "));
        context.write(key, val);
        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_pudaocurrentday_apply_inc";
    }

    @Override
    public String getType() {
        return RecordType.PD_CURRENT_DAY_APPLY_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "朴道-单日借贷申请";
    }

}
